LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-02-2011, 05:45 PM   #1
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Python "IOError: [Errno 24] Too many open files"


Hi all,

I'm trying to write a mediaplayer for my phone + computer in python... It is going well, but I ran into a problem when I moved the programme from my phone (where it worked) to my computer (where it didn't). The error I got was:
Code:
File "./hearse.py", line 169, in getSongInfo
File "/home/joshua/scripts/python2/myMusic.py", line 120, in getSongTitle
File "/usr/lib64/python2.6/site-packages/mutagen/__init__.py", line 75, in __init__
File "/usr/lib64/python2.6/site-packages/mutagen/mp4.py", line 657, in load
IOError: [Errno 24] Too many open files: '/home/joshua/Music/Billy Joel/Billy Joel CD2/01 My Life.m4a'
Exception KeyboardInterrupt in <module 'threading' from '/usr/lib64/python2.6/threading.pyc'> ignored
As you can see, I'm using mutagen to get the metadata for all the files on my computer, and it raises an IOError saying I have too many open files. My thoughts were that this was because my computer has more songs on than my phone, and I had some kind of file descriptor leakage... However, I then redefined the __builtin__.file and __builtin__.open variables so that I could monitor when I was opening and closing files. I also kept a running total of how many files I had open. This total goes between 0 and 1 until the error is raised, which implies to me that I am actually closing all the files I open. Also, it seems that the file that causes the error is the 1011th file - I was wondering whether 1011+stdin+stderr+stdout+file descriptors for curses added up to 1028. But I can't see whether or not that would help find a solution...

Does anyone have any idea why this might be happening? Thanks a lot.


EDIT:
Hm, I thought of running the following line while the programme is still running:
Code:
ls -l /proc/`ps aux | grep hearse | egrep -v grep | awk '{print $2}'`/fd | less
I get a heckuva lot of links pointing to things like "socket:[38657]", with only the number changing. There are also one or two open .mp3 files, strangely... But it seems that there are over 900 of these socket links. They're all coloured red, which I'm guessing means that they're broken links. Again, any clues?

Last edited by Snark1994; 02-02-2011 at 05:57 PM.
 
Old 02-02-2011, 06:40 PM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
why don't you show what your code looks like?
 
1 members found this post helpful.
Old 02-03-2011, 06:51 PM   #3
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632

Original Poster
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Goodness I feel like a fool... Sorry, I should have done that first it was late at night, and I didn't think of doing so. When I started stripping the code down for posting, I discovered the troublesome piece of code - I was asking it to listen to the gstreamer pipeline's bus, but wasn't removing the watcher or disconnecting the bus in my cleanup code for the music player class

Well, thanks for the prompting
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"IOError: [Errno 30] Read-only file system" when installing SME Server 8 from USB penyuan Linux - Newbie 2 11-22-2010 02:28 PM
[SOLVED] yum [Errno 4] IOError sulekha Fedora 3 10-16-2010 03:23 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
User "list" running process "python" TroelsSmit Linux - Newbie 2 02-22-2005 04:55 AM
"X-MS" cant open because "x-Multimedia System" cant access files at "smb&qu ponchy5 Linux - Networking 0 03-29-2004 11:18 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration